DSN = 'dbname=postgres;username=postgres;password=20041209'
class SimpleQuoter(object):
    def sqlquote(x=None):
        return "'bar'"

import sys
import psycopg2

#print "Opening connection using dns:",DSN
conn = psycopg2.connect("dbname='postgres' user='postgres' host='localhost' password='20041209'");

cur = conn.cursor()
cur.execute("""select id,name from test """)
rows = cur.fetchall()
print "\n Show me the databases:\n"

for row in rows:
    print row[0],row['name'][0]

cur.execute("""insert into test(id,name)values(nextval('seq1'),'{"odpsoft","yhr"}')""")
conn.commit()
cur.close()
conn.close()

